package practice5;

import java.util.Scanner;

public class P8667 {

    static int[] a;
    static int[] b;
    static int[] c;
    static int n;
    static int count=0;

    public static void dfs(int step,int num){
        if(step==4){
            count++;
            return;
        }
        for(int i=1;i<=n;i++){
            if(step==1){
                dfs(step+1,a[i]);
            }else if(step==2){
                if(b[i]>num){
                    dfs(step+1,b[i]);
                }
            }else{
                if(c[i]>num){
                    dfs(step+1,c[i]);
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        a=new int[n+1];
        b=new int[n+1];
        c=new int[n+1];
        for(int i=1;i<=n;i++){
            a[i]=sc.nextInt();
        }
        for(int i=1;i<=n;i++){
            b[i]=sc.nextInt();
        }
        for(int i=1;i<=n;i++){
            c[i]=sc.nextInt();
        }
        dfs(1,0);
        System.out.println(count);
    }
}
